const mongoose = require("../config/db");
const moment = require('moment')
const NewsSchema = mongoose.Schema({
  news_name: {
    type: String,
    required: true,
  },
  communities: {
    type: String,
    required: true,
  },
  star_num: {
    type: Number,
    default: 0, // 默认0
    required: true,
  },
  creator: {
    type: String,
    required: true,
  },
  add_time: {
    type: Date,
    default: moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
  }
}, {
  versionKey: false
})
const NewsModel = mongoose.model("News", NewsSchema, "news");
// NewsModel.create({
//   "news_name": "新闻名称",
//   "communities": "所属社团",
//   "creator": "创建者",
//   "star_num": 56
// });
module.exports = NewsModel;